package org.example.qqrobot.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.qqrobot.model.dto.InvitationQueryDTO;
import org.example.qqrobot.model.pojo.Invitation;
import org.example.qqrobot.model.pojo.Product;

import java.util.List;

@Mapper
public interface InvitationMapper {


    List<Invitation> query(InvitationQueryDTO invitationQueryDTO);

    @Insert("insert into invitation (writer, image, youlike, content, title, label_id, create_time) values (#{writer},#{image},#{youlike},#{content},#{title},#{labelId},#{createTime})")
    void save(Invitation invitation);

    @Select("select *from invitation where id = #{invitationId}")
    Invitation findById(Long invitationId);

    void update(Invitation invitation);

    @Select("select youlike from invitation where id = #{invitationId}")
    Long findLikeById(Long invitationId);

    @Update("update invitation set youlike = #{like} where id = #{invitationId}")
    void updateLikeById(Long like, Long invitationId);

    @Select("select writer from invitation where id=#{id}")
    Long findWriterById(Long id);

    List<Invitation> queryByName(String queryName);

    @Select("select *from invitation where writer = #{currentId}")
    List<Invitation> findByWriterId(Long currentId);
}
